"""合同页面"""
from selenium.webdriver.common.by import By

from page.base_page import BasePage


class AgreementPage(BasePage):
    url="/index.php?m=contract"
    agreement_locator = (By.LINK_TEXT, "合同")
    table_locator = (By.CSS_SELECTOR, "#form1 > table > tbody")
    show_locator = (By.LINK_TEXT, "查看")
    edit_locator = (By.LINK_TEXT, "编辑")
    btn_add_agreement_locator = (By.LINK_TEXT, "添加合同")
    def add_agreement(self):
        #点击添加合同
        self.find_element(self.btn_add_agreement_locator).click()
    def show_first_agreement(self):
        #点击第一个的查看合同
        trs=self.driver.find_elements(*self.table_locator)
        trs[0].find_element(*self.show_locator).click()
    def edit_first_agreement(self):
        #点击第一个合同的编辑
        trs=self.driver.find_elements(*self.table_locator)
        trs[0].find_element(*self.edit_locator).click()